<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>用户登录页面</h1>
    <form name="" action="/user/login" method="post" enctype="application/x-www-form-urlencoded"><br>
        <input name="phone" placeholder="手机号"><br>
        <input type="password" name="passwd" placeholder="口令"><br>
        <button>登录</button><a href="#">没有账号则先去注册</a>
    </form>
    <div id="val_info" style="color: red">
        {{ msg }}
    </div>
    <script>
        function $(id) {
            return document.getElementById(id)
        }

        //设置表单提交函数
        document.forms[0].onsubmit = function (ev) {
            if(! /\d{11}/.test(this.phone.value)) {
                $('val_info').innerHTML = '手机号必须是11位'
                return false;
            }

            if(! /\w{6,}/.test(this.passwd.value)) {
                $('val_info').innerHTML = '口令是包含数字和字母的至少6位'
                return false;
            }

            $('val_info').innerHTML = ''
        }
    </script>
</body>
</html>